/*
 * EasyCamera
 *
 * Copyright (c) 2020.  Frezrik frezrik@126.com
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 *
 */

package com.camera.uvchelper;

import android.content.Context;

import com.serenegiant.usb.UVCCamera;

public class UVCCameraHandler extends AbstractUVCCameraHandler {

    /**
     * create UVCCameraHandler, use MediaVideoBufferEncoder, default bandwidth
     *
     * @param parent
     * @param width
     * @param height
     * @param format either UVCCamera.FRAME_FORMAT_YUYV(0) or UVCCamera.FRAME_FORMAT_MJPEG(1)
     *
     * @return
     */
    public static final UVCCameraHandler createHandler(Context parent, int width, int height,
                                                       int format) {
        return createHandler(parent, 2, width, height, format, UVCCamera.DEFAULT_BANDWIDTH);
    }

    /**
     * create UVCCameraHandler
     *
     * @param parent
     * @param encoderType     0: use MediaSurfaceEncoder, 1: use MediaVideoEncoder, 2: use
     *                        MediaVideoBufferEncoder
     * @param width
     * @param height
     * @param format          either UVCCamera.FRAME_FORMAT_YUYV(0) or UVCCamera
     *                        .FRAME_FORMAT_MJPEG(1)
     * @param bandwidthFactor
     *
     * @return
     */
    public static final UVCCameraHandler createHandler(Context parent, int encoderType, int width
            , int height, int format, float bandwidthFactor) {
        CameraThread thread = new CameraThread(UVCCameraHandler.class, parent, null, encoderType,
                width, height, format, bandwidthFactor);
        thread.start();
        return (UVCCameraHandler) thread.getHandler();
    }

    protected UVCCameraHandler(final CameraThread thread) {
        super(thread);
    }

}
